package megrez.bussiness.audit;

import java.time.Instant;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.MapKeyColumn;
import javax.persistence.Table;

import lombok.Getter;
import lombok.Setter;
import megrez.common.jpa.AbstractIdEntity;

/**
 * 持久化审计事件实体
 *  
 * @author Lucky Yang
 * @since 0.0.1
 */
@Getter
@Setter
@Entity
@Table(name = "persistent_audit_event")
public class PersistentAuditEvent extends AbstractIdEntity {
    @Column(nullable = false)
    private String principal;

    @Column
    private Instant eventDate;
    @Column
    private String eventType;

    @ElementCollection
    @MapKeyColumn(name = "name")
    @Column(name = "value")
    @CollectionTable(name = "persistent_audit_event_data", joinColumns=@JoinColumn(name="event_id"))
    private Map<String, String> data = new HashMap<>(); 
}
